package com.justrun.zjutsystem.zjutsystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.justrun.response.ResultCodeEnum;
import com.justrun.response.ResultEntity;
import com.justrun.utils.ExcelUtils;
import com.justrun.zjutsystem.zjutsystem.dtos.AddTeacherDto;
import com.justrun.zjutsystem.zjutsystem.entity.Teacher;
import com.justrun.zjutsystem.zjutsystem.mapper.TeacherMapper;
import com.justrun.zjutsystem.zjutsystem.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * <p>
 * 教师用户信息表 前端控制器
 * </p>
 *
 * @author chandler
 * @since 2020-09-27
 */
@Slf4j
@RestController
@RequestMapping("/zjutsystem/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @GetMapping("/getTeacherList")
    public ResultEntity getTearcherInfo(@RequestParam("teacherId") String teacherId,
                                        @RequestParam("teacherName") String teacherName,
                                        @RequestParam("gender") String gender,
                                        @RequestParam(value = "pageIndex", defaultValue = "1") Integer pageIndex,
                                        @RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {

        return teacherService.getTeacherList(teacherId, teacherName, gender, pageIndex, pageSize);

    }


    @PostMapping("/add")
    public ResultEntity addTeacher(@RequestBody Teacher teacher) {
        System.out.println("进入方法");

        return teacherService.addTeacher(teacher);
    }


    @GetMapping("/modifyStatus")
    public ResultEntity exchangeStatus(@RequestParam(value = "teacherId", required = true) String teacherId,
                                       @RequestParam(value = "status", required = true) String status) {
//        1.根据teacherId即username到sys_user表中设置status
        return teacherService.turnStatus(teacherId, status);

//        2.然后再查找teacherSelectVo

    }


}

